import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import {longLimtVal, longLimtValAndNotBlank, rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '名称',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '上班时间',
    align:"center",
    dataIndex: 'workTime'
   },
   {
    title: '下班时间',
    align:"center",
    dataIndex: 'leaveTime'
   },
   {
    title: '上班前签到有效时长',
    align:"center",
    dataIndex: 'workTimeBefore'
   },
   {
    title: '上班后签到有效时长',
    align:"center",
    dataIndex: 'workTimeAfter'
   },
   {
    title: '下班前签退有效时长',
    align:"center",
    dataIndex: 'leaveTimeBefore'
   },
   {
    title: '下班后签退有效时长',
    align:"center",
    dataIndex: 'leaveTimeAfter'
   },
   {
    title: '允许迟到分钟数',
    align:"center",
    dataIndex: 'allowLateMinute'
   },
   {
    title: '允许早退分钟数',
    align:"center",
    dataIndex: 'allowEarlyLeaveMinute'
   },
  {
    title: '早退多少算旷工',
    align:"center",
    dataIndex: 'absenceLeave'
  },
  {
    title: '迟到多少算旷工',
    align:"center",
    dataIndex: 'absenceLate'
  },

];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "名称",
      field: 'name',
      component: 'Input',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '时段名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入名称！'},
      ];
    },
  },
  {
    label: '',
    field: 'ruleId',
    component: 'Input',
    show:false,
  },
  {
    label: '上班时间',
    field: 'workTime',
    component: 'TimePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'HH:mm:ss'
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入上班时间!'},
      ];
    },
  },
  {
    label: '下班时间',
    field: 'leaveTime',
    component: 'TimePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'HH:mm:ss'
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入下班时间!'},
      ];
    },
  },
  {
    label: '上班前签到有效时长',
    field: 'workTimeBefore',
    component: 'InputNumber',
    defaultValue:60*3,
    suffix:"(单位：分)",
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入上班前签到有效时长!'},
          ];
     },
  },
  {
    label: '上班后签到有效时长',
    field: 'workTimeAfter',
    defaultValue:30,
    suffix:"(单位：分)",
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入上班后签到有效时长!'},
          ];
     },
  },
  {
    label: '下班前签退有效时长',
    field: 'leaveTimeBefore',
    defaultValue:30,
    suffix:"(单位：分)",
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入下班前签退有效时长!'},
          ];
     },
  },
  {
    label: '下班后签退有效时长',
    field: 'leaveTimeAfter',
    defaultValue:60*3,
    suffix:"(单位：分)",
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入下班后签退有效时长!'},
          ];
     },
  },
  {
    label: '允许迟到',
    field: 'allowLateMinute',
    defaultValue:0,
    suffix:"(单位：分)",
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入允许迟到分钟数!'},
          ];
     },
  },
  {
    label: '允许早退',
    field: 'allowEarlyLeaveMinute',
    suffix:"(单位：分)",
    defaultValue:0,
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入允许早退分钟数!'},
          ];
     },
  },
  {
    label: '迟到多少算旷工',
    field: 'absenceLate',
    suffix:"(单位：分)",
    defaultValue:30,
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入迟到多少算旷工分钟数!'},
      ];
    },
  },
  {
    label: '早退多少算旷工',
    field: 'absenceLeave',
    defaultValue:30,
    suffix:"(单位：分)",
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入迟到多少算旷工分钟数!'},
      ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  name: {title: '名称',order: 0,view: 'text', type: 'string',},
  workTime: {title: '上班时间',order: 1,view: 'text', type: 'string',},
  leaveTime: {title: '下班时间',order: 2,view: 'text', type: 'string',},
  workTimeBefore: {title: '上班前签到有效时长',order: 3,view: 'number', type: 'number',},
  workTimeAfter: {title: '上班后签到有效时长',order: 4,view: 'number', type: 'number',},
  leaveTimeBefore: {title: '下班前签退有效时长',order: 5,view: 'number', type: 'number',},
  leaveTimeAfter: {title: '下班后签退有效时长',order: 6,view: 'number', type: 'number',},
  allowLateMinute: {title: '允许迟到分钟数',order: 7,view: 'number', type: 'number',},
  allowEarlyLeaveMinute: {title: '允许早退分钟数',order: 8,view: 'number', type: 'number',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
